home *** CD-ROM | disk | FTP | other *** search
-
- #include "QD3D.h"
- #include "QD3DMath.h"
-
- #include "DragSupport.h"
- #include "WindowObj.h"
-
- #include "QuickDraw3DSupport.h"
- #include "MainWindow.h"
-
-
-
-
- //-----------------------------------------------------------------------
- // •• MAIN WINDOW ••
- //-----------------------------------------------------------------------
- static void MainWindowCreate(WindowObjHndl);
- static void MainWindowIdle(WindowObjHndl);
-
-
- //-----------------------------------------------------------------------
-
- Boolean Is3DWindow(WindowPtr win)
- {
- WindowObjHndl obj;
- Boolean is3DWindow;
-
- is3DWindow = false;
-
- if (win != NULL) {
- obj = (WindowObjHndl) GetWRefCon(win);
- is3DWindow = ((*obj)->type == 'Main');
- }
-
- return is3DWindow;
- }
-
- //-----------------------------------------------------------------------
-
- void MainWindowNotify(WindowObjHndl obj, long message)
- {
- switch (message) {
- case kCreateNotification:
- MainWindowCreate(obj);
- break;
-
- case kCloseNotification:
- DisposeObjWindow(obj);
- break;
-
- case kAdjustMenusNotification: {
- MenuHandle fileMenu = GetMenuHandle(kFileMenu);
- MenuHandle editMenu = GetMenuHandle(kEditMenu);
-
- if (fileMenu != NULL) {
- EnableItem(fileMenu, kNewItem);
- EnableItem(fileMenu, kOpenItem);
- EnableItem(fileMenu, kCloseItem);
- EnableItem(fileMenu, kQuitItem);
- }
-
- if (editMenu != NULL) {
- DisableItem(editMenu, kUndoItem);
- DisableItem(editMenu, kCutItem);
- DisableItem(editMenu, kCopyItem);
- DisableItem(editMenu, kPasteItem);
- DisableItem(editMenu, kClearItem);
- DisableItem(editMenu, kSelectAllItem);
- }
- }
- break;
-
- case kDestroyNotification:
- RemoveDragHandlers((*obj)->window);
- break;
-
- case kIdleNotification:
- MainWindowIdle(obj);
- break;
- }
- }
-
- //-----------------------------------------------------------------------
-
- void MainWindowKeys(WindowObjHndl obj, long message, short mods)
- {
- #pragma unused (obj, message, mods)
- SysBeep(20);
- }
-
- //-----------------------------------------------------------------------
-
- void MainWindowClick(WindowObjHndl obj, EventRecord *event, long message)
- {
- #pragma unused (obj, message, event)
- }
-
- //-----------------------------------------------------------------------
-
- void MainWindowDraw(WindowObjHndl obj, short depth)
- {
- #pragma unused (depth)
- WindowPtr win = (*obj)->window;
- DocumentHdl theDocument;
-
- theDocument = GetDocumentHdl(obj);
-
- if ((theDocument != NULL) && (**theDocument).fModel != NULL) {
- HLock((Handle) theDocument);
- Q3View_StartRendering((**theDocument).fView) ;
- do {
- (void) SubmitScene(theDocument) ;
- } while (Q3View_EndRendering((**theDocument).fView) == kQ3ViewStatusRetraverse);
-
- HUnlock((Handle) theDocument);
- }
- }
-
- //-----------------------------------------------------------------------
- // we received a null event, rotate the object if there is one.
- //-----------------------------------------------------------------------
- static void MainWindowIdle(WindowObjHndl obj)
- {
- WindowPtr win = (*obj)->window;
- TQ3Matrix4x4 tmp;
- Rect theRect;
- DocumentHdl theDocument;
-
- theDocument = GetDocumentHdl(obj) ;
-
- if (theDocument != NULL) {
- theRect = win->portRect;
- Q3Matrix4x4_SetRotate_XYZ(&tmp, 0.05, 0.06, 0.08);
- HLock((Handle) theDocument);
- Q3Matrix4x4_Multiply(&(**theDocument).fRotation, &tmp, &(**theDocument).fRotation);
- HUnlock((Handle) theDocument);
- InvalRect(&theRect);
- }
- }
-
- //-----------------------------------------------------------------------
-
- static void MainWindowCreate(WindowObjHndl obj)
- {
- DocumentHdl doc;
-
- doc = CreateDocument((*obj)->window);
- require(doc != NULL, CreateDocumentFailed);
-
- TextFont(monaco);
- TextSize(9);
-
- (*obj)->refCon = (unsigned long) doc;
-
- if (InstallDragHandlers((*obj)->window) != noErr)
- DebugStr("\pDrag handler installation failed.");
-
- // SetWindowGeometry((*obj)->window, 1);
-
- CreateDocumentFailed:
- return;
- }